<template>
  <svg @contextmenu.prevent.stop="checkState">
    <g v-if="state===1">
      <polygon points="20 10,30 26,10 26" fill="white" stroke="white" stroke-width="4"></polygon>
      <polygon points="10 34,30 34,20 50" fill="#92908F" stroke="#92908F" stroke-width="4"></polygon>
      <ellipse cx = "20" cy = "30" rx="16" ry="8" style="fill: #92908F"></ellipse>
    </g>

      <g v-else-if="state===0"  style="transform: translate(50px,7px)rotate(90deg);border: 1px solid red">
          <polygon points="20 10,30 26,10 26" fill="white" stroke="white" stroke-width="4"></polygon>
          <polygon points="10 34,30 34,20 50" fill="#92908F" stroke="#92908F" stroke-width="4"></polygon>
          <ellipse cx = "20" cy = "30" rx="16" ry="8" style="fill: #92908F"></ellipse>
      </g>

  </svg>
</template>

<script>
import {submitOperateRecord} from "@/api/api";

export default {
  name: "KongZhiBaShou",
  props: {
		name: {
		  required: true, // 控件名称
		  type: String
		},
      info:{
        type:Object,
        default: function (){
          return {

          }
        }
      },
		state: {    // 控件状态
		  required: true,
		  type: Number,
		},
      deviceName:{
            type: String,
            default: ''
        },
     jianGeMing: {
            type: String,
            default: ''
        },
	},
  components: {
  },
  methods: {
      checkState(){
          this.desc=this.$store.state.operDescData.find(item=>item.type==='jc'&&item.comType==='开关').desc;
          this.desc=this.desc.replace('jgName',this.info.jg_name).replace('devName',this.info.state_desc).replace('state', (Number(this.state) === 0 ? "就地" : "远方"))
          if (this.deviceName.includes('解锁')){
              this.desc=this.desc.replace('远方','联锁').replace('就地','解锁')
          }
          submitOperateRecord( {log_desc:this.desc})
      },
		// 右击菜单
  }
}
</script>

<style scoped>
</style>
